# Q2. 按距离统计房屋对数目 I
from collections import deque
from typing import *


class Solution:
    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:
        next = [[] for _ in range(n)]
        next[0].append(1)
        next[-1].append(n - 2)
        for i in range(1, n - 1):
            next[i].append(i + 1)
            next[i].append(i - 1)
        next[x - 1].append(y - 1)
        next[y - 1].append(x - 1)
        ans = [0] * n
        for i in range(n):
            visit = [False] * n
            visit[i] = True
            q = [i]
            roadCnt = 0
            while q:
                nq = []
                for qi in q:
                    for nxt in next[qi]:
                        if not visit[nxt]:
                            visit[nxt] = True
                            ans[roadCnt] += 1
                            nq.append(nxt)
                roadCnt += 1
                q = nq
        return ans


s = Solution()
print(s.countOfPairs(8, 4, 7))
